package soap;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class WeatherInterfaceImpl implements WeatherInterface {

    @Override
    public List<WeatherModel> queryWeather(String cityName) throws Exception {
        //构造三天的天气结果
        Calendar calendar = Calendar.getInstance();
        int day = calendar.get(Calendar.DATE);
        //第一天的天气
        WeatherModel weatherModel_1 = new WeatherModel();
        weatherModel_1.setDate(new Date());
        weatherModel_1.setDetail("晴朗");
        weatherModel_1.setTemperature_max(30);
        weatherModel_1.setTemperature_min(23);
        //第二天的天气
        WeatherModel weatherModel_2 = new WeatherModel();
        calendar.set(Calendar.DATE, day + 1);
        weatherModel_2.setDate(calendar.getTime());
        weatherModel_2.setDetail("晴转多云");
        weatherModel_2.setTemperature_max(28);
        weatherModel_2.setTemperature_min(21);
        //第三天的天气
        WeatherModel weatherModel_3 = new WeatherModel();
        calendar.set(Calendar.DATE, day + 2);
        weatherModel_3.setDate(calendar.getTime());
        weatherModel_3.setDetail("多云转小雨");
        weatherModel_3.setTemperature_max(25);
        weatherModel_3.setTemperature_min(18);

        List<WeatherModel> list = new ArrayList<>();
        list.add(weatherModel_1);
        list.add(weatherModel_2);
        list.add(weatherModel_3);
        //返回三天的天气
        return list;
    }
}
